using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;

namespace QLTV.Reports
{
    public partial class rptDanhSachDuKienDieuDong : DevExpress.XtraReports.UI.XtraReport
    {
        public rptDanhSachDuKienDieuDong()
        {
            InitializeComponent();
        }
        Database.dsReportTableAdapters.tblCrewTableAdapter tadCrew = new Database.dsReportTableAdapters.tblCrewTableAdapter();
        Database.dsReportTableAdapters.tblRankTableAdapter tadRank = new Database.dsReportTableAdapters.tblRankTableAdapter();
        Database.dsVessel.tblVesselDataTable dtVessel;
        public void loadData(int planID, int vesselID)
        {
            using (Database.dsVesselTableAdapters.tblVesselTableAdapter tadVessel = new Database.dsVesselTableAdapters.tblVesselTableAdapter())
            {
                dtVessel = new Database.dsVessel.tblVesselDataTable();
                //get vesselDetail
                tadVessel.FillbyID(dtVessel, vesselID);
                using (Database.dsReportTableAdapters.tblKeHoachTableAdapter tadKeHoach = new Database.dsReportTableAdapters.tblKeHoachTableAdapter())
                {
                    tadKeHoach.FillBy(dsReport1.tblKeHoach, planID);
                }
                tblToTrinhTableAdapter.Fill(dsReport1.tblToTrinh, planID);
                txtTenTau.Text = dtVessel.Rows[0]["cVesselName"].ToString();
                txtTenCang.Text = dsReport1.tblKeHoach.Rows[0]["CangDuKien"].ToString();
            }
            if (dsReport1.tblKeHoach.Rows[0]["NgayDuKienThucHien"].ToString() != "")
                txtTGDK.Text = ((DateTime)dsReport1.tblKeHoach.Rows[0]["NgayDuKienThucHien"]).ToString("dd-MM-yyyy");
        }
        int _stt = 0;
        private void stt_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            _stt++;
            stt.Text = _stt.ToString();
           
            if (txtCrewID.Text == "")
                txtRank.Text = tadRank.GetDataByID((Int32)tadCrew.GetByID(txtNextID.Text)[0]["nRankID"])[0]["cRankName"].ToString();
        }

        private void txtCrewID_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (tadCrew.GetByID(txtCrewID.Text).Rows.Count > 0)
            {
                txtCrewID.Text = tadCrew.GetByID(txtCrewID.Text)[0]["FullName"].ToString();

                //
            }
        }

        private void txtNextID_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (tadCrew.GetByID(txtNextID.Text).Rows.Count > 0)
            {
                txtNextID.Text = tadCrew.GetByID(txtNextID.Text)[0]["FullName"].ToString();

            }
        }

        private void txtNguoiLap_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            txtNguoiLap.Text = Program.EmployeeName;
        }
    }
}
